// 岗位管理路由
import { Router } from 'express';
import { authMiddleware } from '@/middlewares/auth.middleware';
import { permissionMiddleware } from '@/middlewares/permission.middleware';
import postController from '@/controllers/system/post.controller';
import { validatePostCreate, validatePostUpdate, validatePostRemove } from '@/validators/system/post.validator';
import { createController } from '@/utils/router/route.controller';

const router = createController(Router());

/**
 * 岗位管理路由
 * 路径前缀：/system/post
 */

// 所有路由均需认证
router.use(authMiddleware);

// ================== 岗位列表相关 ==================
// 获取岗位列表
router.get('/list', permissionMiddleware('system:post:list'), postController.list);
// 导出岗位列表
router.post('/export', permissionMiddleware('system:post:export'), postController.export);
// 获取岗位选择框列表
router.get('/optionselect', permissionMiddleware('system:post:list'), postController.optionSelect);
// 查询岗位详细
router.get('/:postId', permissionMiddleware('system:post:query'), postController.getInfo);

// ================== 新增、修改、删除 ==================
// 新增岗位
router.POST('', permissionMiddleware('system:post:add'), validatePostCreate, postController.add);
// 修改岗位
router.PUT('', permissionMiddleware('system:post:edit'), validatePostUpdate, postController.update);
// 删除岗位
router.DELETE('/:postIds', permissionMiddleware('system:post:remove'), validatePostRemove, postController.remove);

export default router; 